# -*- coding: utf-8 -*-
import web;
import predef;
import logging;

PREFIX = '' 
API_KEY='01939220edcbfff404bab662c963ffdc'
SECRET='41e14b8e8fe1cec8'

request_tokens = {}
access_tokens = {}

MAX_INVITING_LIST = 6;

def html_header():
    return """
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>Douchaos</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <body>
    <div id="maxw">
    <h1>Douchaos</h1>"""
    
def html_footer():
    return """
    </div>
    </body>
</html>"""

def sendMail(uid,touid,song=None):
    if(song==None):
        return  """
                <h2>向豆瓣用户推荐DouChaos...</h2>
                <form action="%s/invite" method="GET">
                <div class="uid">
                     你的豆瓣 ID&nbsp;: &nbsp;&nbsp;<span><a target="blank" href="http://www.douban.com/people/%s/">%s</a></span><span class="logout"></span>
                </div>
                <div class="hid">
                  <label for="hid">Ta 的豆瓣 ID:</label><span>
                  <input type="text" id="toid" name="toid" tabindex="1" value="%s">
                  <input type="hidden" value="%s" name="uid" id="uid" /> 
                  <input type="hidden" value="send" name="op" id="op" /> 
                </div>
                <input type="submit" value="发送推荐邮件">
                </form>""" % (predef.HOST,uid,uid,touid,uid)
    else:
        return  """
                <h2>向豆瓣用户推荐DouChaos...</h2>
                <form action="%s/invite" method="GET">
                <div class="uid">
                     你的豆瓣 ID&nbsp;: &nbsp;&nbsp;<span><a target="blank" href="http://www.douban.com/people/%s/">%s</a></span><span class="logout"></span>
                </div>
                <div class="hid">
                  <label for="hid">Ta 的豆瓣 ID:</label><span>
                  <input type="text" id="toid" name="toid" tabindex="1" value="%s">
                  <input type="hidden" value="%s" name="uid" id="uid" /> 
                  <input type="hidden" value="send" name="op" id="op" /> 
                </div>
                 <div class="csong">
                     <input type="checkbox" value="true" name="withsong" id="withsong"/>
                     <label for="hid">推荐你现在听的歌曲：%s</label><span> 
                     <input type="hidden" value="%s" name="sid" id="sid" /> 
                 </div>
                <input type="submit" value="发送推荐邮件">
                </form>""" % (predef.HOST,uid,uid,touid,uid,song["name"],song['sid']);

def mailContentTemplate(song=None):
    if(song==None):
        return """你也来试试DouChaos嘛""";
    else:
        return """你也来试试DouChaos嘛，我给你推荐了:%s - %s"""%(song['name'],song['artist']);

class Invite:
    def POST(self):
        pass;           
                
                
        
    def GET(self):
        pass
            